package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Menu;
import com.itheima.health.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Wang
 * @version 1.0.0
 * @createTime 2020年08月25日 14:23:00
 * @Description: Menu 前端控制
 */
@RestController
@Slf4j
@RequestMapping("/menu")
public class MenuController {

    @Reference
    private MenuService menuService;

    /**
     * 查询所有的菜单信息
     * @return
     */
    @GetMapping("/findAll")
    @PreAuthorize("hasAuthority('MENU_QUERY')")
    public Result findAll() {
        List<Menu> menuList = menuService.findAll();
        return new Result(true, MessageConst.ACTION_SUCCESS, menuList);
    }
}
